import { defineStore } from 'pinia'
import { ElMessage } from 'element-plus'

const basepath = '/st'
export const useTestStore = defineStore('test', {
  state: () => {
    return {
      index: -1,
      dialogFormVisible: false,
      dialogFormTitle: '1234',

      tableData: [
        {
          value: 'vue',
          link: 'https://github.com/vuejs/vue',
          address: 'No. 189, Grove St, Los Angeles'
        },
        {
          value: 'element',
          link: 'https://github.com/ElemeFE/element',
          address: 'No. 189, Grove St, Los Angeles'
        },
        {
          value: 'cooking',
          link: 'https://github.com/ElemeFE/cooking',
          address: 'No. 189, Grove St, Los Angeles'
        },
        {
          value: 'mint-ui',
          link: 'https://github.com/ElemeFE/mint-ui',
          address: 'No. 189, Grove St, Los Angeles'
        },
        {
          value: 'vuex',
          link: 'https://github.com/vuejs/vuex',
          address: 'No. 189, Grove St, Los Angeles'
        },
        {
          value: 'vue-router',
          link: 'https://github.com/vuejs/vue-router',
          address: 'No. 189, Grove St, Los Angeles'
        },
        {
          value: 'babel',
          link: 'https://github.com/babel/babel',
          address: 'No. 189, Grove St, Los Angeles'
        }
      ],

      city: '沈阳',
      currentvalue: '',

      formdata: {
        sid: -1,
        snm: '沈阳站',
        snmpy: 'shenyangzhan',
        city: '沈阳',
        citypy: 'shenyang'
      }
    }
  },
  // 也可以这样定义
  // state: () => ({ count: 0 })
  actions: {
    preInfo4Mod(index, row) {
      this.index = index
      this.formdata = JSON.parse(JSON.stringify(row))
      this.dialogFormTitle = '编辑。。。。。'
      this.currentvalue = this.formdata.value
      this.dialogFormVisible = true
    },

    preInfo4Add() {
      this.formdata = JSON.parse(JSON.stringify(this.formdata)) //  clone
      this.formdata.sid = -1
      this.dialogFormTitle = `新增站点`

      this.dialogFormVisible = true
    }

    /**
     * 加载数据
     */
  }
})
